import java.util.*;
import java.util.stream.Collectors;

import javafx.util.Pair;

public class Main {
    static int n, m;
    final static int N = 300010;
    static int[] a = new int[N];
    static int[] s = new int[N];
    static ArrayList<Integer> alls = new ArrayList<>();
    static ArrayList<Pair<Integer, Integer>> add = new ArrayList<>();
    static ArrayList<Pair<Integer, Integer>> query = new ArrayList<>();

    static int find(int x) {
        int l = 0, r = alls.size() - 1;
        while (l < r) {
            int mid = (l + r) / 2;
            if (alls.get(mid) >= x) r = mid;
            else l = mid + 1;
        }
        return r + 1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt(), c = sc.nextInt();
            Pair<Integer, Integer> pair = new Pair<>(x, c);
            add.add(pair);
            alls.add(x);
        }


        for (int i = 0; i < m; i++) {
            int l = sc.nextInt(), r = sc.nextInt();
            Pair<Integer, Integer> pair = new Pair<>(l, r);
            query.add(pair);
            alls.add(l);
            alls.add(r);
        }

        //排序 + 去重
        Collections.sort(alls);
        List<Integer> newlist = alls.stream().distinct().collect(Collectors.toList());
        alls.clear();
        alls.addAll(newlist);

        //处理插入
        for (Pair<Integer, Integer> pair : add) {
            int x = find(pair.getKey());
            a[x] += pair.getValue();
        }

        //预处理前缀和
        for (int i = 1; i <= alls.size(); i++)
            s[i] = s[i - 1] + a[i];

        //处理询问
        for (Pair<Integer, Integer> item : query) {
            int l = find(item.getKey()), r = find(item.getValue());
            System.out.println(s[r] - s[l - 1]);
        }

    }
}